package com.aki.ai_property.controller;

import com.aki.ai_property.entity.Contract;
import com.aki.ai_property.service.intf.ContractService;
import com.aki.ai_property.vo.PageBean;
import com.aki.ai_property.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 孙贺鹏
 * @date 2022/8/27
 */
@RestController
@RequestMapping("/api/contract/")
public class ContractContraller {
    @Autowired
    private ContractService service;
    /** 新增 */
    @PostMapping("save.do")
    public Result save(Contract contract){
        return service.save(contract);
    }

    /** 修改 */
    @PostMapping("update.do")
    public Result update(Contract contract){
        return service.update(contract);
    }

    /** 删除 */
    @GetMapping("delete.do")
    public Result delete(int id){
        return service.delete(id);
    }

    /** 查询 */
    @GetMapping("all.do")
    public PageBean page(String contractName, int page, int limit){
        return service.selectPage(contractName, page, limit);
    }


    @GetMapping("alldto.do")
    public Result all(){
        return service.all();
    }

}
